<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>网页更换皮肤演示实例</title>
	<link rel="stylesheet" type="text/css" href="../css/ChangeSkin.css"/>
	<link rel="stylesheet" type="text/css" href="../css/red.css"/>
</head>
<body>
	<div id="content">
		<ul id="skinItem">
			<li id="red" title="红色" class="current">红色</li>
			<li id="green" title="绿色">绿色</li>
			<li id="black" title="黑色">黑色</li>
		</ul>
		
		<ul id="nav">
			<li><a href="javascript::">新闻</a></li>
			<li><a href="javascript::">娱乐</a></li>
			<li><a href="javascript::">体育</a></li>
			<li><a href="javascript::">影视</a></li>
			<li><a href="javascript::">科技</a></li>
			<li class="last"><a href="javascript::">音乐</a></li>
		</ul>
	</div>
	
	<script type="text/javascript">
		//读取页面更换皮肤的样式表文件
		var oLink = document.getElementsByTagName("link")[1];
		var oSkin = document.getElementById("skinItem").getElementsByTagName("li");
		//console.log(oSkin);
		
		for (var i = 0; i < oSkin.length; i++) {
			oSkin[i].onclick = function(){
				console.log(oSkin);
				for(var j in oSkin)
					oSkin[j].className = "";
					this.className = "current";
					oLink['href'] = "../css/" + this.id + ".css";
			}
		}
	</script>
</body>
</html>